﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单详情</title>
    <link rel="stylesheet" href="css/amazeui.css">
    <script src="js/vue.js"></script>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="js/common.js"></script>
    <link href="css/common.css" rel="stylesheet" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <style>
        * {
            padding: 0;
            border: 0;
            margin: 0;
        }

        .veads_01 {
            height: 6rem;
            width: 100%;
            overflow: hidden;
            padding: 0 3%;
            line-height: 6rem;
            z-index: 999999999;
            position: relative;
            background: #fff;
            border-bottom: 1px solid #d3d3d3;
        }

        .veads1_i1 {
            display: block;
            float: left;
            margin-top: 6%;
            width: 2.5%;
        }

        .veads1_s1 {
            display: block;
            text-align: center;
            font-size: 1.8rem;
        }

        .ordts_01 {
            width: 100%;
            overflow: hidden;
            padding: 0 3%;
        }

        .orde_02 {
            background: #efefef;
            width: 100%;
            padding: 1% 0;
        }

        .orde_03 {
            position: fixed;
            bottom: 0;
            width: 100%;
        }

        /*一下为临时*/
        .veas_10 {
            background: rgba(0,0,0,0.2);
            position: fixed;
            width: 100%;
            height: 100%;
            top: 0;
            z-index: 100000000;
        }

        .veas10_d1 {
            background: #fff;
            width: 100%;
            height: 75%;
            position: absolute;
            bottom: 0;
        }

        .veas10_d2 {
            width: 100%;
            padding: 3% 5%;
            overflow: hidden;
            border-bottom: 1px solid #d3d3d3;
        }

        .veas10_i1 {
            display: block;
            float: left;
            width: 3%;
            margin-top: 0.6%;
            margin-right: 10%;
        }

        .veas10_d3 {
            overflow: hidden;
            float: left;
            width: 25%;
            margin-right: 3%;
        }

        .veas10_s1 {
            height: 2.4rem;
            width: 50%;
            background: #efefef;
            border-radius: 3px;
            display: block;
            float: left;
            margin-right: 10%;
        }

        .veas10_s2 {
            display: block;
            float: left;
            width: 37%;
            margin-top: 4%;
            font-size: 1.2rem;
        }

        .veas10_d4 {
            overflow-y: auto;
            height: 50%;
            width: 100%;
        }

        .veas10_d5 {
            overflow: hidden;
            margin-top: 5%;
            padding-left: 15%;
        }

        .veas10_s3 {
            font-size: 1.2rem;
            display: block;
            margin-right: 2.6%;
            margin-bottom: 10%;
            margin-top: 11%;
            text-align: center;
        }

        .veas10_d6 {
            width: 100%;
            padding: 0 2%;
            overflow: hidden;
        }

        .veas10_s4 {
            font-size: 1.1rem;
            display: block;
            margin-right: 3.3%;
            width: 100%;
            /*margin-bottom: 0.8rem;*/
            height: 2.1rem;
            margin-bottom: 11.7%;
        }

        .veas10_s5 {
            display: block;
            height: 1.8rem;
            /*width: 9%;*/
            background: #efefef;
            border-radius: 5px;
            font-size: 1.1rem;
            text-align: center;
            color: #efefef;
            line-height: 1.8rem;
            float: left;
            margin-right: 1.8%;
            margin-bottom: 2%;
        }

        .veas10_d7 {
            padding: 3% 7%;
            width: 100%;
            margin-top: 1%;
        }

        .veas10_s6 {
            font-size: 2rem;
            display: block;
            margin-bottom: 3%;
        }

        .veas10_d8 {
            width: 10.5rem;
            border: 1px solid #23c788;
            overflow: hidden;
            padding-bottom: 0.3rem;
            float: left;
        }

        .veas10_s7 {
            display: block;
            font-size: 1.4rem;
            color: #727272;
            padding-left: 10%;
        }

        .veas10_s8 {
            display: block;
            color: #ff7676;
            font-size: 1.22rem;
            padding-left: 6%;
        }

        .veas10_i2 {
            display: block;
            float: right;
            margin-top: -20%;
            margin-right: 3%;
            width: 8%;
        }

        .veas10_d9 {
            overflow: hidden;
        }

        .veas10_d10 {
            overflow-x: auto;
        }

        .veas10_but {
            font-size: 1.8rem;
            text-align: center;
            color: #fff;
            background: #dadada;
            position: absolute;
            bottom: 0;
            border-radius: inherit;
            width: 100%;
            padding: 4% 0;
        }

        .veas10_s5_other {
            color: #fff;
            background: #23c788;
        }

        .other_veas10_d {
            height: 1.8rem;
            width: 90%;
            overflow: hidden;
            margin-right: 1.8%;
            margin-bottom: 9%;
            position: relative;
        }

        .other_veas10_s {
            height: 1.8rem;
            border-radius: 5px;
            font-size: 1.1rem;
            text-align: center;
            color: #efefef;
            line-height: 1.8rem;
            background: #23c788;
            position: absolute;
            display: none;
        }

        .veas10_but_other {
            background: #23c788;
        }

        .veas10_d11 {
            margin-bottom: 11.7%;
            border: 1px solid #efefef;
            background: #efefef;
            border-radius: 5px;
            height: 2.1rem;
        }

        .am-g_other {
            background: #23c788;
            color: #fff;
        }

        .vdts_s {
            border-radius: 5px;
            background: #efefef;
        }

        .vdts {
            width: 3.8rem;
        }

        .vedtls {
            background: #23c788;
            color: #fff;
            text-align: center;
            font-size: 0.8rem;
        }

        .veas10_other {
            width: 100%;
            height: 25%;
            position: absolute;
            top: 0;
        }
    </style>
</head>
<body>
    <div id="vult" v-cloak>

        <header data-am-widget="header" class="am-header am-header-default" style="background-color: #FFFFFF; border-bottom: 1px solid rgb(211, 211, 211);">
            <div class="am-header-left am-header-nav" onclick="goBack()">
                <a href="javascript:" class="">
                    <img class="am-header-icon-custom" src="images/veas07.png" alt="" />
                </a>
            </div>
            <h4 class="am-header-title" style=" color: black;">订单详情</h4>
            <div class="am-header-right am-header-nav"><a href="/Wap/Index.html" class="am-header-icon am-icon-home" style="color: #A9A9A9; "></a></div>
        </header>
        <ul class="am-list" style="    margin-bottom: 0.1rem;margin-top: 0">
            <li style="overflow: hidden;border-top: none;padding: 3% 0;color: #747474;font-size: 1.8rem;padding-left: 3%;"><span style="float:left;">用户信息</span></li>
        </ul>
        <div class="ordts_01">
            <ul class="am-list" style="margin-bottom: 0">
                <li style="overflow: hidden;border-top: none;padding: 3% 0;font-weight: 500"><span style="float:left;">用户名</span><span style="float:right;">{{userinfo.nickName}}</span></li>
                <li style="overflow: hidden;;border-bottom: none;padding: 3% 0;font-weight: 500"><span style="float:left;">电话</span><span style="float:right;">{{userinfo.Phone}}</span></li>
            </ul>
        </div>
        <div class="orde_02"></div>
        <ul class="am-list" style="    margin-bottom: 0.1rem;margin-top: 0">
            <li style="overflow: hidden;border-top: none;padding: 3% 0;color: #747474;font-size: 1.8rem;padding-left: 3%;"><span style="float:left;">场地信息</span></li>
        </ul>
        <div class="ordts_01">
            <ul class="am-list" style="margin-bottom: 0">
                <li style="overflow: hidden;border-top: none;padding: 3% 0;font-weight: 500"><span style="float:left;font-size: 1.9rem">{{Venueinfo.Name}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500" v-on:click="toMap()"><span style="float:left;">场馆地址</span><span style="float:right;">{{Venueinfo.Adress}}</span><img src="images/veas03.png" alt="" style="margin-top: 1%;margin-right: 1%;width: 4.2%;float: right;"></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">场馆</span><span style="float:right;">{{Sport.Name}}</span></li>
            </ul>
        </div>
        <div class="orde_02"></div>
        <ul class="am-list" style="    margin-bottom: 0.1rem;margin-top: 0">
            <li style="overflow: hidden;border-top: none;padding: 3% 0;color: #747474;font-size: 1.8rem;padding-left: 3%;"><span style="float:left;">订单信息</span></li>
        </ul>
        <div class="ordts_01" style="margin-bottom: 0rem">
            <ul class="am-list" style="margin-bottom: 0">
                <li style="overflow: hidden;border-top: none;padding: 3% 0;font-weight: 500"><span style="float:left;">订单号</span><span style="float:right;">{{orderinfo.number}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">订单时间</span><span style="float:right;">{{orderinfo.createTime}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">总金额</span><span style="float:right;">{{orderinfo.payMoney}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">订单状态</span><span style="float:right;color:#ff9129">{{orderinfo.State==0?"未付款":orderinfo.State==1?"已付款":orderinfo.State==-1?"已过期":orderinfo.State==-2?"已取消":"状态异常"}}</span></li>
            </ul>
            <ul class="am-list" v-for="list in orderDetails" v-bind:style="{ 'margin-bottom': ((orderinfo.State==0 && torder.discountGId=='')? '0em': '7em') }">
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">时间</span><span style="float:right;">{{list.startTime}} - {{list.endTime}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">场地 {{(orderinfo.State==0 && torder.discountGId=='')? '0em': '7em'}}</span><span style="float:right;">{{list.Name}}</span></li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">场地费用</span><span style="float:right;">{{list.Price}}</span></li>
            </ul>
        </div>
        <ul class="am-list" style="    margin-bottom: 0.1rem;margin-top: 0" v-if="orderinfo.State==0 && torder.discountGId==''">
            <li style="overflow: hidden;border-top: none;padding: 3% 0;color: #747474;font-size: 1.8rem;padding-left: 3%;"><span style="float:left;">优惠信息</span></li>
        </ul>
        <div class="ordts_01" style="margin-bottom: 7rem" v-if="orderinfo.State==0 && torder.discountGId==''">
            <ul class="am-list" style="margin-bottom: 0">
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500"><span style="float:left;">会员卡优惠</span><span style="float:right;" v-on:click="xuanze">选择优惠</span></li>
            </ul>
        </div>
        <div class="orde_03" v-if="orderinfo.State==0 && torder.discountGId!=''">
            <button type="button" class="am-btn am-btn-default" v-on:click="cancel" style="float:left;width: 49.9%;border: none;background: #cccccc;color: #fff;height: 5.5rem;">取消订单</button>
            <button type="button" class="am-btn am-btn-default" v-on:click="useDiscountpay()" style="width: 49.9%; border: none;background: #23c788;color: #fff;height: 5.5rem;">确定支付</button>
        </div>
        <!--<div class="orde_03" v-if="orderinfo.State==0">
            <button type="button" class="am-btn am-btn-default" v-on:click="cancel" style="float:left;width: 49.9%;border: none;background: #cccccc;color: #fff;height: 5.5rem;">取消</button>
            <button type="button" class="am-btn am-btn-default" v-on:click="pay" style="width: 49.9%; border: none;background: #23c788;color: #fff;height: 5.5rem;">付款</button>
        </div>-->



        <div class="veas_10" v-if="isshow">
            <div class="veas10_other">

            </div>
            <div class="veas10_d1" id="veas10_d6_01">
                <div class="veas10_d2">
                    <img src="images/veas07.png" alt="" class="veas10_i1" v-on:click="closewindows()">
                    选择优惠
                </div>

                <div class="veas10_d4">
                    <div class="am-g am-g-fixed veas10_d6" id="">
                        <div class="am-u-sm-2" style="padding-right: 0;width:100%">
                            <div v-if="discount.length<=0">
                                您暂无可用优惠券
                            </div>
                            <div v-if="discount.length>0">
                                <div style="border:none;" v-for="(list,index) in discount">
                                    <div>
                                        <label><input type="radio" name="discount" v-on:click="useCard(list.discountGId,list.discount.Type,list.discountValue)" />{{list.discount.Name}} 优惠：{{list.discount.Type==1?list.discountValue + "元":list.discountValue +"%"}} 每月可用：{{list.discount.number}}  (剩余：{{list.discount.number-list.count}})</label>
                                    </div>
                                </div>
                                <div style="border:none;">
                                    <div>
                                        <label><input type="radio" name="discount" v-on:click="useCard('',-1,0)" />不使用</label>
                                    </div>
                                </div>
                            </div>
                            <div>待支付:{{money}}元</div>
                            <button type="button" class="am-btn am-btn-default" v-on:click="cancel" style="float:left;width: 49.9%;border: none;background: #cccccc;color: #fff;height: 5.5rem;">取消订单</button>
                            <button type="button" class="am-btn am-btn-default" v-on:click="useDiscountpay()" style="width: 49.9%; border: none;background: #23c788;color: #fff;height: 5.5rem;">确定支付</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</body>
</html>
<script>
    $(function () {
        var orderid = $.getParam("Id");
        page.orderid = orderid;
        page.getInfo();
    })

    var page = new Vue({
        el: '#vult',
        data: {
            orderid: 0,
            orderinfo: [],
            torder :{},//T_ORDER数据
            userinfo: [],//用户信息
            Venueinfo: [],//场管信息
            Sport: [],//场地运动信息
            orderDetails: [],//订场信息
            isshow: false,//是否显示优惠券/卡弹框
            discount: [],//优惠券/卡数组
            useDiscount: "",//使用的优惠券/卡Gid
            money:0,
        },
        methods: {
            getInfo: function () {
                var that = this;
                $.ajax({
                    type: 'POST',
                    url: apiUrl + '/Api/Mine/ReserveOrderInfo',
                    data: { "Id": that.orderid },
                    success: function (data) {
                        console.log(data);
                        if (data.errcode == 0) {
                            that.orderinfo = data.data;
                            that.torder = data.data.order;
                            that.userinfo = data.data.User;
                            that.Venueinfo = data.data.Venue;
                            that.orderDetails = data.data.orderDetails;
                            that.Sport = data.data.Sport;
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
            },
            useCard: function (discountGId,disType,disvalue) {
                this.useDiscount = discountGId;
                if(disType==1)
                {
                    this.money = this.orderinfo.payMoney - disvalue;
                }
                else if(disType == 2)
                {
                    this.money = this.orderinfo.payMoney - this.orderinfo.payMoney * disvalue / 100;
                }
                else if(disType==-1)
                {
                    this.money = this.orderinfo.payMoney;
                }
            },
            xuanze: function () {
                var that = this;
                that.money = that.orderinfo.payMoney;
                $.ajax({
                    type: 'POST',
                    url: apiUrl + '/Api/Mine/GetCard',
                    data: { "venueId": that.Venueinfo.gId, "money": that.money },
                    success: function (data) {
                        console.log(data);
                        if (data.errcode == 0) {
                            that.discount = data.data;
                        } else if (data.errcode == -1) {
                            that.discount = data.errmsg;
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
                this.isshow = true;
            },
            closewindows: function () {
                this.isshow = false;
            },
            toMap: function () {
                location.href = 'map.html?xPoint=' + this.Venueinfo.xPoint + "&yPoint=" + this.Venueinfo.yPoint;
            },
            useDiscountpay: function () {
                var that = this;

                $.ajax({
                    url: apiUrl + "/Api/Field/createDisOrder",
                    data: { "Id": that.orderid, "useDiscountGid": that.useDiscount },
                    type: "POST",
                    success: function (data) {
                        if (data.errcode == 0) {
                            //alert(data.errmsg);

                            $.ajax({
                                url: apiUrl + data.errmsg,
                                //data: { "money": 80 },
                                type: "POST",
                                success: function (data) {
                                    if (data.errcode == 0) {
                                        alert(data.errmsg);
                                        location.replace(location.href);
                                    } else {
                                        alert(data.errmsg);
                                    }

                                },
                                //error: function () {
                                //    alert("响应失败");
                                //}
                            })

                        } else {
                            alert(data.errmsg);
                        }

                    },
                    //error: function () {
                    //    alert("响应失败");
                    //}
                })
            },
            pay: function () {
                var that = this;
                if (typeof WeixinJSBridge == "undefined") {
                    if (document.addEventListener) {
                        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                    }
                    else if (document.attachEvent) {
                        document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                    }
                }
                else {
                    $.ajax({
                        url: apiUrl + "/Api/Weixin/WeixinPay",
                        data: { "Id": that.orderid },
                        type: "POST",
                        success: function (data) {
                            if (data.errcode == 0) {
                                WeixinJSBridge.invoke(
                                  'getBrandWCPayRequest',
                                  data.data,
                                  function (res) {
                                      if (res.err_msg == "get_brand_wcpay_request:ok") {
                                          alert("支付成功");
                                          location.replace(location.href);
                                      }
                                  }
                                );
                            } else {
                                alert(data.errmsg);
                            }

                        },
                        //error: function () {
                        //    alert("响应失败");
                        //}
                    })

                }
                return false;
                $.ajax({
                    url: thisUrl + "/Api/Field/ReserveOrderPay",
                    data: { Id: that.orderid },
                    type: "POST",
                    success: function (data) {
                        if (data.errcode == 0) {
                            alert("支付成功");
                            location.replace(location.href);
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器响应异常");
                    //}
                })
            },
            cancel: function () {
                var that = this;
                if(confirm("确定取消订单吗？")){
                    $.ajax({
                        url: thisUrl + "/Api/Field/ReserveOrderCancel",
                        data: { Id: that.orderid },
                        type: "POST",
                        success: function (data) {
                            if (data.errcode == 0) {
                                alert("取消成功");
                                location.replace(location.href);
                            } else {
                                alert(data.errmsg);
                            }
                        },
                        //error: function () {
                        //    alert("服务器响应异常");
                        //}
                    })
                }

            }
        }
    });
</script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="/Content/js/wxconfig.js"></script>
<script>
    wx.ready(function () {
        wx.share("飞羽体育", "飞羽体育是一款关于订场app，主要目标人群是运动爱好者。功能包括GPS精准定位附近运动休闲娱乐场馆，为您提供方便、快捷的运动方式及参考，让你感受运动的快乐。", location.href, thisUrl + '/Wap/images/vult17.png');
    })
</script>
